import requst from '../../../util/Http.js'
Page({
  data:{
    list:['全部','未支付','已支付','待收货'],
    setindex:0,
    orders:[],
    obj:{},
  },
  onShow(){
    let self=this;
    let obj=wx.getStorageSync('userinfo');
    requst('Index/geTOrderList',{id:obj.id,type:0},'post').then(res=>{
      if(res.code==200){
        // res.data
        self.setData({
          obj,
          orders:res.data
        })
      }
    })
  },
  setIndex(e){
    let self=this;
    this.setData({
      setindex:e.currentTarget.dataset.index
    })
    let {obj}=this.data;
    requst('/Index/geTOrderList',{id:obj.id,type:e.currentTarget.dataset.index},'post').then(res=>{
      if(res.code==200){
        // res.data
        self.setData({
          orders:res.data
        })
      }
    })
  },

  setDetli(e){
    let {orders}=this.data
    let index=e.currentTarget.dataset.index;
    let id=orders[index].id
    wx.navigateTo({
      url: '/page/component/orders/orders?id='+id,
    })      
  },

})